package com.liang.blog.security.jwt;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author：YanWenLiang
 * @Date:2023-06-29-9:35
 */
public class AuthContextHolder {
    //获取当前用户id
    public static Long getUserId(HttpServletRequest request) {
        return JwtHelper.getUserId(getToken(request));
    }

    //获取当前用户账号
    public static String getUserAccount(HttpServletRequest request) {
        return JwtHelper.getAccount(getToken(request));
    }

    // 获取用户唯一标识
    public static String getUserKey(HttpServletRequest request){
        return JwtHelper.getUserKey(getToken(request));
    }

    public static String getToken(HttpServletRequest request){
        return request.getHeader("token");
    }

}

